Skip to content

Conversation

@bdash
Copy link
Contributor

@bdash bdash commented Jul 10, 2025

A few correctness, performance, and memory fixes in the shared cache view. See the commit messages for specifics.

BNSharedCacheEntry apiEntry;
apiEntry.path = BNAllocString(entry.GetFilePath().c_str());
apiEntry.name = BNAllocString(entry.GetFileName().c_str());
auto path = entry.GetFilePath();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch 🥇

@emesare emesare self-requested a review July 10, 2025 15:07
bdash added 3 commits July 10, 2025 16:13
`GetRegionAt` was really providing the semantics of
`GetRegionContaining` due to `m_regions` being an `AddressRangeMap` and
using transparent comparators to allow `find` to work with any address
in the range.

`GetRegionAt` is updated to verify that the start address of the region
that was found matches the requested address. `GetRegionContaining` is
updated to use `AddressRangeMap::find` rather than doing a linear search
over all regions.
We're copying `std::string` objects that know their length. There's no
reason to force a call to `strlen`.
Avoid copying the vector of symbols where possible. When no filter
string is applied we no longer copy the entire vector symbols by having
the symbols used for display be indirected via a pointer. It points
either to the unfiltered symbols or the filtered symbols.

Some unncessary copies have been removed by using `std::move` where
appropriate.

Filtering has been updated to avoid `std::vector::reserve` /
`std::vector::shrink_to_fit` in favor of letting the filtered vector
control its own growth and reuse its buffer. This avoids allocating a
~100MB buffer every time we update the filter only to later reallocate
and move the contents into a smaller buffer. Instead the buffer grows
via `std::vector`'s usual growth algorithm and it is preserved across
filter calls to avoid unnecessarily reallocating it, and only shrink the
buffer if it has shrunk significantly vs previous iterations.
@bdash bdash merged commit 55d3bda into dev Jul 10, 2025
4 of 5 checks passed
@bdash bdash deleted the dsc-misc-fixes branch July 10, 2025 23:30
@emesare emesare added this to the Helion milestone Jul 23, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants